package com.c7.bm.mybatis.service.impl;

import com.c7.bm.mybatis.model.C7ActivityImageQr;
import com.c7.bm.mybatis.service.ActivityImageQrService;
import com.c7.bm.mybatis.util.ResponseWrapper;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author <a href="mailto:chenjunwen@xiaomagouche.com">Duke(陈俊文)</a>
 * @create 17/7/8  下午1:42
 */
@Service
public class ActivityImageQrServiceImpl extends BaseService<C7ActivityImageQr> implements ActivityImageQrService {

    @Override
    public ResponseWrapper getImageQr(Long imageId) {
        ResponseWrapper responseWrapper = new ResponseWrapper();
        Example example = new Example(C7ActivityImageQr.class);
        Example.Criteria criteria = example.createCriteria();
        if (imageId != null) {
            criteria.andEqualTo("activityImageId", imageId);
        }
        List<C7ActivityImageQr> list = this.selectByExample(example);
        if (list.size() > 0) {
            responseWrapper.setStatus(0);
            responseWrapper.addAttribute("imageQr", list.get(0));
        } else {

        }
        return responseWrapper;
    }
}
